/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * SelectImage.java
 *
 * Created on 18-feb-2009, 17:13:01
 */

package edu.upf.grupE.interftest;

import java.io.File;
import javax.swing.JFileChooser;

/**
 *
 * @author Oscar
 */
public class SelectImage extends javax.swing.JFrame {
    ImageSelection im;
    VideoSelection vid;
    /** Creates new form SelectImage */
    public SelectImage(ImageSelection im, VideoSelection vid) {
        this.vid=vid;
        this.im=im;
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jFileChooser1 = new javax.swing.JFileChooser();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jFileChooser1 = new javax.swing.JFileChooser();
        Filter filter1 = new Filter("JPG");
        Filter filter2 = new Filter("GIF");
        Filter filter3 = new Filter("PNG");

        jFileChooser1.setAcceptAllFileFilterUsed(false);
        jFileChooser1.setFileFilter(filter1);
        jFileChooser1.setFileFilter(filter2);
        jFileChooser1.setFileFilter(filter3);
        jFileChooser1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jFileChooser1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jFileChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jFileChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jFileChooser1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFileChooser1ActionPerformed
        // TODO add your handling code here:
          String command = evt.getActionCommand();
    if (command == null) return; // Can this happen? Probably not. Call me paranoid.
    if (command.equals(JFileChooser.APPROVE_SELECTION)){
        System.out.println("ola");
        File f= jFileChooser1.getSelectedFile();
        String path= f.getPath();
        AddPicAlbum add= new AddPicAlbum(im, path, vid);
        add.setVisible(true);
        dispose();}
    else if (command.equals(JFileChooser.CANCEL_SELECTION)){
        System.out.println("olas");
        dispose();}

    }//GEN-LAST:event_jFileChooser1ActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
             //   new SelectImage().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JFileChooser jFileChooser1;
    // End of variables declaration//GEN-END:variables

}
